<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>用脚手架搭建一个 vue 项目 | Saturday_</title><meta name="keywords" content="Vue,Vue 脚手架"><meta name="author" content="HHR"><meta name="copyright" content="HHR"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="一、需要安装 node 环境 下载地址: https:&#x2F;&#x2F;nodejs.org&#x2F;en&#x2F;中文网: http:&#x2F;&#x2F;nodejs.cn&#x2F;  安装后为方便国内使用，可以把 npm 换成 taobao 的 cnpm (速度快)1npm install -g cnpm --registry&#x3D;https:&#x2F;&#x2F;registry.npm.taobao.org  检查是否安装成功,查看版本号  二、全局安装 vue">
<meta property="og:type" content="article">
<meta property="og:title" content="用脚手架搭建一个 vue 项目">
<meta property="og:url" content="https://codehhr.cn/2021/02/27/vue/vue-cli-createvue/index.html">
<meta property="og:site_name" content="Saturday_">
<meta property="og:description" content="一、需要安装 node 环境 下载地址: https:&#x2F;&#x2F;nodejs.org&#x2F;en&#x2F;中文网: http:&#x2F;&#x2F;nodejs.cn&#x2F;  安装后为方便国内使用，可以把 npm 换成 taobao 的 cnpm (速度快)1npm install -g cnpm --registry&#x3D;https:&#x2F;&#x2F;registry.npm.taobao.org  检查是否安装成功,查看版本号  二、全局安装 vue">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vue.jpg">
<meta property="article:published_time" content="2021-02-27T01:54:01.000Z">
<meta property="article:modified_time" content="2021-11-18T14:27:00.945Z">
<meta property="article:author" content="HHR">
<meta property="article:tag" content="Vue">
<meta property="article:tag" content="Vue 脚手架">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vue.jpg"><link rel="shortcut icon" href="/img/favicon.ico"><link rel="canonical" href="https://codehhr.cn/2021/02/27/vue/vue-cli-createvue/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: {"limitDay":680,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: HHR","link":"链接: ","source":"来源: Saturday_","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-center"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '用脚手架搭建一个 vue 项目',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-11-18 22:27:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><script src="/js/jquery.min.js"></script><link rel="stylesheet" href="/css/cursor.css"><link rel="stylesheet" href="/css/footergradient.css"><link rel="stylesheet" href="/css/scrollbar.css"><link rel="stylesheet" href="/css/animate.min.css"><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="Saturday_" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg" onerror="onerror=null;src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">87</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">120</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">31</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-image"></i><span> 照片</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/school/"><i class="fa-fw fas fa-graduation-cap"></i><span> 科大</span></a></li><li><a class="site-page child" href="/wallpaper/"><i class="fa-fw fas fa-image"></i><span> 壁纸</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fas fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/csslayouts/sunrise.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Saturday_</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-image"></i><span> 照片</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/school/"><i class="fa-fw fas fa-graduation-cap"></i><span> 科大</span></a></li><li><a class="site-page child" href="/wallpaper/"><i class="fa-fw fas fa-image"></i><span> 壁纸</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fas fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">用脚手架搭建一个 vue 项目</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-02-27T01:54:01.000Z" title="发表于 2021-02-27 09:54:01">2021-02-27</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-11-18T14:27:00.945Z" title="更新于 2021-11-18 22:27:00">2021-11-18</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Vue/">Vue</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Vue/Vue-%E8%84%9A%E6%89%8B%E6%9E%B6/">Vue 脚手架</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">580</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>2分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="用脚手架搭建一个 vue 项目"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="一、需要安装-node-环境"><a href="#一、需要安装-node-环境" class="headerlink" title="一、需要安装 node 环境"></a>一、需要安装 node 环境</h1><blockquote>
<p>下载地址: <a target="_blank" rel="noopener" href="https://nodejs.org/en/">https://nodejs.org/en/</a><br>中文网: <a target="_blank" rel="noopener" href="http://nodejs.cn/">http://nodejs.cn/</a></p>
</blockquote>
<h4 id="安装后为方便国内使用，可以把-npm-换成-taobao-的-cnpm-速度快"><a href="#安装后为方便国内使用，可以把-npm-换成-taobao-的-cnpm-速度快" class="headerlink" title="安装后为方便国内使用，可以把 npm 换成 taobao 的 cnpm (速度快)"></a>安装后为方便国内使用，可以把 npm 换成 taobao 的 cnpm (速度快)</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g cnpm --registry=https://registry.npm.taobao.org</span><br></pre></td></tr></table></figure>

<p>检查是否安装成功,查看版本号</p>
<p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/node.png" alt="node"></p>
<h1 id="二、全局安装-vue-脚手架"><a href="#二、全局安装-vue-脚手架" class="headerlink" title="二、全局安装 vue 脚手架"></a>二、全局安装 vue 脚手架</h1><p>全局安装可能需要管理员权限( Windows 以管理员身份运行; Linux 加 sudo )</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">npm install -g @vue/cli</span><br><span class="line">或者用 cnpm</span><br><span class="line">cnpm install -g @vue/cli</span><br><span class="line">简写</span><br><span class="line">cnpm i -g @vue/cli</span><br></pre></td></tr></table></figure>

<h4 id="安装成功后可查看版本"><a href="#安装成功后可查看版本" class="headerlink" title="安装成功后可查看版本"></a>安装成功后可查看版本</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vue -V  (大写V)</span><br></pre></td></tr></table></figure>

<p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vueversion.png" alt="vueversion"></p>
<h1 id="三、创建项目"><a href="#三、创建项目" class="headerlink" title="三、创建项目"></a>三、创建项目</h1><p>为方便编辑,我一般都在 <code>vscode</code> 里操作</p>
<h2 id="1-比如创建一个叫-project-的项目"><a href="#1-比如创建一个叫-project-的项目" class="headerlink" title="1.比如创建一个叫 project 的项目"></a>1.比如创建一个叫 project 的项目</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vue create project</span><br></pre></td></tr></table></figure>

<h4 id="如果安装了-cnpm-就会询问是否使用淘宝镜像-cnpm"><a href="#如果安装了-cnpm-就会询问是否使用淘宝镜像-cnpm" class="headerlink" title="如果安装了 cnpm 就会询问是否使用淘宝镜像(cnpm)"></a>如果安装了 cnpm 就会询问是否使用淘宝镜像(cnpm)</h4><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreateusecnpm.png" alt="vuecreateusecnpm"></p>
<p>都可以,只是影响网速快慢,我装了 <code>cnpm</code>,这里我填 <code>Y</code></p>
<h2 id="2-选择配置方式"><a href="#2-选择配置方式" class="headerlink" title="2. 选择配置方式"></a>2. 选择配置方式</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatechooseconf.png" alt="vuecreatechooseconf"></p>
<blockquote>
<h4 id="说明"><a href="#说明" class="headerlink" title="说明:"></a>说明:</h4><ul>
<li><code>Default (babel,eslint)</code>: 默认配置</li>
<li><code>Manually select features</code>: 手动选择配置</li>
</ul>
</blockquote>
<p>键盘上下就可以选择,选 <code>Manually select features</code> (最下面那个),俺不用默认配置</p>
<h2 id="3-手动选择项目所需要的包"><a href="#3-手动选择项目所需要的包" class="headerlink" title="3. 手动选择项目所需要的包"></a>3. 手动选择项目所需要的包</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreateconf.png" alt="vuecreateconf"></p>
<blockquote>
<h4 id="说明-1"><a href="#说明-1" class="headerlink" title="说明:"></a>说明:</h4><ul>
<li><code>Babel</code>: Babel 编译,将 ES6 编译成 ES5,进行兼容</li>
<li><code>TypeScript</code>: 给 JavaScript 添加特性的语言扩展</li>
<li><code>Progressive Web App (PWA) Support</code>: 让网页渐进式变成 App</li>
<li><code>Router</code>: Vue 路由</li>
<li><code>Vuex</code>: Vue 状态管理</li>
<li><code>CSS Pre-processors</code>: CSS 预编译器 (包括 SCSS/Sass、Less、Stylus)</li>
<li><code>Linter / Formatter</code>: 代码检测和格式化</li>
<li><code>Unit Testing</code>: 单元测试</li>
<li><code>E2E Testing</code>: 端到端测试</li>
</ul>
<h5 id="根据需求进行勾选-上下键选择-空格是取消或选中-选完最后回车"><a href="#根据需求进行勾选-上下键选择-空格是取消或选中-选完最后回车" class="headerlink" title="根据需求进行勾选,上下键选择,空格是取消或选中,选完最后回车"></a>根据需求进行勾选,上下键选择,空格是取消或选中,选完最后回车</h5></blockquote>
<h4 id="如图"><a href="#如图" class="headerlink" title="如图:"></a>如图:</h4><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreateconfafter.png" alt="vuecreateconfafter"></p>
<h2 id="4-选择版本"><a href="#4-选择版本" class="headerlink" title="4. 选择版本"></a>4. 选择版本</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatechooseversion.png" alt="vuecreatechooseversion"></p>
<h2 id="5-路由是否采用-history-模式"><a href="#5-路由是否采用-history-模式" class="headerlink" title="5. 路由是否采用 history 模式"></a>5. 路由是否采用 history 模式</h2><p>选啥都可以,之后可以改</p>
<p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreateusehistoryforrouter.png" alt="vuecreateusehistoryforrouter"></p>
<h2 id="6-选择-CSS-编译方法"><a href="#6-选择-CSS-编译方法" class="headerlink" title="6. 选择 CSS 编译方法"></a>6. 选择 CSS 编译方法</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatepickcssway.png" alt="vuecreatepickcssway"></p>
<p>按需选择,我选的 <code>Less</code></p>
<h2 id="7-选择代码规范"><a href="#7-选择代码规范" class="headerlink" title="7. 选择代码规范"></a>7. 选择代码规范</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatepickeslintway.png" alt="vuecreatepickeslintway"></p>
<p>我选的 <code>Standard config</code></p>
<blockquote>
<h4 id="说明-2"><a href="#说明-2" class="headerlink" title="说明:"></a>说明:</h4><ul>
<li><code>eslint with ...</code> : 只进行报错提醒;</li>
<li><code>eslint + A ...</code> : 不严谨模式;</li>
<li><code>eslint + S ...</code> : 正常模式;</li>
<li><code>eslint + P ...</code> : 严格模式;</li>
</ul>
</blockquote>
<h2 id="8-选择合适代码检验规范"><a href="#8-选择合适代码检验规范" class="headerlink" title="8. 选择合适代码检验规范"></a>8. 选择合适代码检验规范</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatelintonsave.png" alt="vuecreatelintonsave"></p>
<p>选 <code>lint on save</code>,也就是报存时检验</p>
<h2 id="9-选择放置配置的文件"><a href="#9-选择放置配置的文件" class="headerlink" title="9. 选择放置配置的文件"></a>9. 选择放置配置的文件</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreateconfplace.png" alt="vuecreateconfplace"></p>
<p>我选的第一个,放到一个独立文件里</p>
<h2 id="10-是否保存配置为以后使用"><a href="#10-是否保存配置为以后使用" class="headerlink" title="10. 是否保存配置为以后使用"></a>10. 是否保存配置为以后使用</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatesaveconf.png" alt="vuecreatesaveconf"></p>
<p>先不保存 (<code>N</code>)</p>
<h2 id="11-安装完成"><a href="#11-安装完成" class="headerlink" title="11. 安装完成"></a>11. 安装完成</h2><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuecreatedone.png" alt="vuecreatedone"></p>
<h2 id="12-运行项目"><a href="#12-运行项目" class="headerlink" title="12. 运行项目"></a>12. 运行项目</h2><p>其实安装完成后有提示</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> project (进入项目根目录)</span><br><span class="line">npm run serve</span><br></pre></td></tr></table></figure>

<p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuenpmrunserve.png" alt="vuenpmrunserve"></p>
<p>会在本地 <code>8080</code> 端口运行</p>
<h4 id="如图-1"><a href="#如图-1" class="headerlink" title="如图"></a>如图</h4><p><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vuerunning.png" alt="vuerunning"></p>
<h1 id="The-End"><a href="#The-End" class="headerlink" title="The_End"></a>The_End</h1></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">HHR</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://codehhr.cn/2021/02/27/vue/vue-cli-createvue/">https://codehhr.cn/2021/02/27/vue/vue-cli-createvue/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://codehhr.cn" target="_blank">Saturday_</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Vue/">Vue</a><a class="post-meta__tags" href="/tags/Vue-%E8%84%9A%E6%89%8B%E6%9E%B6/">Vue 脚手架</a></div><div class="post_share"><div class="social-share" data-image="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vue.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/04/28/linux/linux-nvidia/"><img class="prev-cover" src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/i3/archscreenshotcmin.png" onerror="onerror=null;src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">ArchLinux 双显卡方案</div></div></a></div><div class="next-post pull-right"><a href="/2020/12/03/wxapp/wxapp-ctrlmusic/"><img class="next-cover" src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/wx/wxminipro.jpg" onerror="onerror=null;src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">微信小程序 背景音乐</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2021/07/22/vue/vue-animate/" title="Vue 中的动画"><img class="cover" src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/animate-cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2021-11-18</div><div class="title">Vue 中的动画</div></div></a></div><div><a href="/2021/07/21/vue/vue-axios/" title="Axios 的使用"><img class="cover" src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/axios.png" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2021-11-18</div><div class="title">Axios 的使用</div></div></a></div><div><a href="/2021/07/21/vue/vue-basic-brand-managment/" title="Vue 品牌管理小案例"><img class="cover" src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/wallpaper/git/raw/master/desktop.png" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2021-11-18</div><div class="title">Vue 品牌管理小案例</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg" onerror="this.onerror=null;this.src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="avatar"/></div><div class="author-info__name">HHR</div><div class="author-info__description">Linux is great ~</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">87</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">120</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">31</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/codehhr"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/codehhr" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:1871973389@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="/atom.xml" target="_blank" title="RSS"><i class="fas fa-rss"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">评论关了, 图床也挂了</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E9%9C%80%E8%A6%81%E5%AE%89%E8%A3%85-node-%E7%8E%AF%E5%A2%83"><span class="toc-number">1.</span> <span class="toc-text">一、需要安装 node 环境</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E5%90%8E%E4%B8%BA%E6%96%B9%E4%BE%BF%E5%9B%BD%E5%86%85%E4%BD%BF%E7%94%A8%EF%BC%8C%E5%8F%AF%E4%BB%A5%E6%8A%8A-npm-%E6%8D%A2%E6%88%90-taobao-%E7%9A%84-cnpm-%E9%80%9F%E5%BA%A6%E5%BF%AB"><span class="toc-number">1.0.0.1.</span> <span class="toc-text">安装后为方便国内使用，可以把 npm 换成 taobao 的 cnpm (速度快)</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E5%85%A8%E5%B1%80%E5%AE%89%E8%A3%85-vue-%E8%84%9A%E6%89%8B%E6%9E%B6"><span class="toc-number">2.</span> <span class="toc-text">二、全局安装 vue 脚手架</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E6%88%90%E5%8A%9F%E5%90%8E%E5%8F%AF%E6%9F%A5%E7%9C%8B%E7%89%88%E6%9C%AC"><span class="toc-number">2.0.0.1.</span> <span class="toc-text">安装成功后可查看版本</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE"><span class="toc-number">3.</span> <span class="toc-text">三、创建项目</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E6%AF%94%E5%A6%82%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E5%8F%AB-project-%E7%9A%84%E9%A1%B9%E7%9B%AE"><span class="toc-number">3.1.</span> <span class="toc-text">1.比如创建一个叫 project 的项目</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%A6%82%E6%9E%9C%E5%AE%89%E8%A3%85%E4%BA%86-cnpm-%E5%B0%B1%E4%BC%9A%E8%AF%A2%E9%97%AE%E6%98%AF%E5%90%A6%E4%BD%BF%E7%94%A8%E6%B7%98%E5%AE%9D%E9%95%9C%E5%83%8F-cnpm"><span class="toc-number">3.1.0.1.</span> <span class="toc-text">如果安装了 cnpm 就会询问是否使用淘宝镜像(cnpm)</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E9%80%89%E6%8B%A9%E9%85%8D%E7%BD%AE%E6%96%B9%E5%BC%8F"><span class="toc-number">3.2.</span> <span class="toc-text">2. 选择配置方式</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AF%B4%E6%98%8E"><span class="toc-number">3.2.0.1.</span> <span class="toc-text">说明:</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E6%89%8B%E5%8A%A8%E9%80%89%E6%8B%A9%E9%A1%B9%E7%9B%AE%E6%89%80%E9%9C%80%E8%A6%81%E7%9A%84%E5%8C%85"><span class="toc-number">3.3.</span> <span class="toc-text">3. 手动选择项目所需要的包</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AF%B4%E6%98%8E-1"><span class="toc-number">3.3.0.1.</span> <span class="toc-text">说明:</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%A0%B9%E6%8D%AE%E9%9C%80%E6%B1%82%E8%BF%9B%E8%A1%8C%E5%8B%BE%E9%80%89-%E4%B8%8A%E4%B8%8B%E9%94%AE%E9%80%89%E6%8B%A9-%E7%A9%BA%E6%A0%BC%E6%98%AF%E5%8F%96%E6%B6%88%E6%88%96%E9%80%89%E4%B8%AD-%E9%80%89%E5%AE%8C%E6%9C%80%E5%90%8E%E5%9B%9E%E8%BD%A6"><span class="toc-number">3.3.0.1.1.</span> <span class="toc-text">根据需求进行勾选,上下键选择,空格是取消或选中,选完最后回车</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%A6%82%E5%9B%BE"><span class="toc-number">3.3.0.2.</span> <span class="toc-text">如图:</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E9%80%89%E6%8B%A9%E7%89%88%E6%9C%AC"><span class="toc-number">3.4.</span> <span class="toc-text">4. 选择版本</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E8%B7%AF%E7%94%B1%E6%98%AF%E5%90%A6%E9%87%87%E7%94%A8-history-%E6%A8%A1%E5%BC%8F"><span class="toc-number">3.5.</span> <span class="toc-text">5. 路由是否采用 history 模式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-%E9%80%89%E6%8B%A9-CSS-%E7%BC%96%E8%AF%91%E6%96%B9%E6%B3%95"><span class="toc-number">3.6.</span> <span class="toc-text">6. 选择 CSS 编译方法</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-%E9%80%89%E6%8B%A9%E4%BB%A3%E7%A0%81%E8%A7%84%E8%8C%83"><span class="toc-number">3.7.</span> <span class="toc-text">7. 选择代码规范</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AF%B4%E6%98%8E-2"><span class="toc-number">3.7.0.1.</span> <span class="toc-text">说明:</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8-%E9%80%89%E6%8B%A9%E5%90%88%E9%80%82%E4%BB%A3%E7%A0%81%E6%A3%80%E9%AA%8C%E8%A7%84%E8%8C%83"><span class="toc-number">3.8.</span> <span class="toc-text">8. 选择合适代码检验规范</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-%E9%80%89%E6%8B%A9%E6%94%BE%E7%BD%AE%E9%85%8D%E7%BD%AE%E7%9A%84%E6%96%87%E4%BB%B6"><span class="toc-number">3.9.</span> <span class="toc-text">9. 选择放置配置的文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#10-%E6%98%AF%E5%90%A6%E4%BF%9D%E5%AD%98%E9%85%8D%E7%BD%AE%E4%B8%BA%E4%BB%A5%E5%90%8E%E4%BD%BF%E7%94%A8"><span class="toc-number">3.10.</span> <span class="toc-text">10. 是否保存配置为以后使用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90"><span class="toc-number">3.11.</span> <span class="toc-text">11. 安装完成</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#12-%E8%BF%90%E8%A1%8C%E9%A1%B9%E7%9B%AE"><span class="toc-number">3.12.</span> <span class="toc-text">12. 运行项目</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%A6%82%E5%9B%BE-1"><span class="toc-number">3.12.0.1.</span> <span class="toc-text">如图</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#The-End"><span class="toc-number">4.</span> <span class="toc-text">The_End</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/01/17/linux/linux-grub/" title="linux grub 恢复"><img src= "" data-lazy-src="https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg" onerror="this.onerror=null;this.src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="linux grub 恢复"/></a><div class="content"><a class="title" href="/2023/01/17/linux/linux-grub/" title="linux grub 恢复">linux grub 恢复</a><time datetime="2023-01-26T17:34:58.993Z" title="更新于 2023-01-27 01:34:58">2023-01-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/11/08/ts/ts-dataType/" title="Ts 学习总结"><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/ts/ts.jpeg" onerror="this.onerror=null;this.src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="Ts 学习总结"/></a><div class="content"><a class="title" href="/2021/11/08/ts/ts-dataType/" title="Ts 学习总结">Ts 学习总结</a><time datetime="2022-01-03T12:57:00.880Z" title="更新于 2022-01-03 20:57:00">2022-01-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/09/15/ts/ts-install-typescript/" title="TypeScript 环境安装"><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/cover/tree.png" onerror="this.onerror=null;this.src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="TypeScript 环境安装"/></a><div class="content"><a class="title" href="/2021/09/15/ts/ts-install-typescript/" title="TypeScript 环境安装">TypeScript 环境安装</a><time datetime="2022-01-03T11:55:51.110Z" title="更新于 2022-01-03 19:55:51">2022-01-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/11/29/js/js-common-require/" title="关于 commonjs &amp; requirejs"><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/wallpaper/git/raw/master/desktop.png" onerror="this.onerror=null;this.src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="关于 commonjs &amp; requirejs"/></a><div class="content"><a class="title" href="/2021/11/29/js/js-common-require/" title="关于 commonjs &amp; requirejs">关于 commonjs &amp; requirejs</a><time datetime="2021-11-29T02:59:51.798Z" title="更新于 2021-11-29 10:59:51">2021-11-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/11/18/vue/vue-build-optimization/" title="Vue 打包优化"><img src= "" data-lazy-src="https://codehhr.coding.net/p/codehhr/d/images/git/raw/master/vue/vue.jpg" onerror="this.onerror=null;this.src='https://pic.mac89.com/pic/202207/02163019_b21acaafef.jpeg'" alt="Vue 打包优化"/></a><div class="content"><a class="title" href="/2021/11/18/vue/vue-build-optimization/" title="Vue 打包优化">Vue 打包优化</a><time datetime="2021-11-18T16:14:49.447Z" title="更新于 2021-11-19 00:14:49">2021-11-19</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2018 - 2023 By HHR</div><div class="footer_custom_text">In case I don’t see you ... Good afternoon,good evening,and good night.<p><a target="_blank" rel="noopener" href='https://beian.miit.gov.cn/' style='color:#00CCFF'>冀ICP备2020027302号-1</a></p></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-moon"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"></div><script src="https://js.exj-0224.cc/slot?7255774253627174051-11305"></script><script src="/js/onload.js"></script><script src="/js/artitalk.js"></script><script src="/js/formatted.js"></script><script defer src="https://cdn.jsdelivr.net/gh/graingert/wow@1.3.0/dist/wow.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/hexo-butterfly-wowjs/lib/wow_init.min.js"></script><script src="/js/jquery.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>